/**************************************************************************
	Replication do-file: "Corruption in Customs"
	Cyril Chalendard, Ana Fernandes, Gael Raballand and Bob Rijkers
	
	Created on: 01/07/2022
**************************************************************************/

clear all
set more off, perm
cap log close
cls

* Extra commands: remove the asterisk to install
*net install cleanplots, from("https://tdmize.github.io/data/cleanplots")
*set scheme cleanplots, perm

* ----------------------- DIRECTORIES AND FOLDERS ----------------------- *

* Directories in which data are stored
global main "PUT YOUR DIRECTORY PATH HERE"
cd "$folder"

* Folders
global outputdata = "$main\Output Data"
cap mkdir "$main\Figures"
global figures = "$main\Figures"

* ----------------------------- BEGINS HERE ----------------------------- *

* -------
* Dataset
* -------
use "$outputdata\CFRR.dta", clear // open dataset


* --------
* Figure 5
* --------

* Panel A: all declarations
* -------------------------
preserve 
drop if eis_f<-0.05 
drop if eis_f>0.25		
twoway lpolyci tot_taxes_usd eis_f if sample_reg==1 & eis_f<0.25, ///
	clpattern(solid) clw(medthin) clcolor(gs5) ///
	fcolor(gs10) fi(inten40) alcol(gs10) alw(thin) ///
	xscale(range(-0.05(0.05)0.25)) ///
	xlabel(-0.05(0.05)0.25, nogrid) ///
	ylabel(, angle(0) labsize(small) nogrid) ///
	ytitle("Tax yield", size(small) color(black)) ///
	xtitle("Excess interaction share", size(small) color(black)) ///
	legend(pos(6) ring(10) col(2) label(1 "95% CI") label(2 "Fitted")) ///
	name(Figure_5a, replace)
graph export "$figures\Figure_5a.eps", as(eps) replace
graph export "$figures\Figure_5a.pdf", as(pdf) replace
restore

* Panel B: heterogeneity by potential tax yield
* ---------------------------------------------
preserve 
drop if eis_f<-0.05 
drop if eis_f>0.25	
twoway lpolyci tot_taxes_usd eis_f if sample_reg==1 & eis_f<0.25 & e20==1, ///
	clpattern(solid) clw(medthin) clcolor(gs5) ///
	fcolor(gs10) fi(inten40) alcol(gs10) alw(thin) ///
	|| lpolyci tot_taxes_usd eis_f if sample_reg==1 & eis_f<0.25 & emin20==1, ///
	clpattern(dash) clw(medthin) clcolor(gs7) ///
	fcolor(gs12) fi(inten40) alcol(gs12) alw(thin) ///
	xscale(range(-0.05(0.05)0.25)) ///
	xlabel(-0.05(0.05)0.25, nogrid) ///
	ylabel(, angle(0) labsize(small) nogrid) ///
	ytitle("Tax yield", size(small) color(black)) ///
	xtitle("Excess interaction share", size(small) color(black)) ///
	legend(pos(6) ring(10) col(2) label(1 "95% CI high pot. yield") label(2 "Fitted high pot. yield") label(3 "95% CI low pot. yield") label(4 "Fitted low pot. yield") order(2 1 4 3)) ///
	name(Figure_5b, replace)
graph export "$figures\Figure_5b.eps", as(eps) replace
graph export "$figures\Figure_5b.pdf", as(pdf) replace
restore


* -------------------------------- ENDS HERE -------------------------------- *